package com.doyled.jump.user;

import java.util.LinkedList;
import java.util.List;

import com.doyled.jump.object.Dice;
import com.doyled.jump.object.Environment;
import com.doyled.jump.object.Horsemen;
import com.doyled.jump.object.Spot;
import com.doyled.jump.user.ai.NewAI;
import com.doyled.jump.util.ChessKind;
import com.doyled.jump.util.HorseState;
import com.doyled.jump.util.TeamInfo;

public class PlayerAI extends User{
	
	NewAI brain;

	public PlayerAI(Environment env, ChessKind kind, TeamInfo teamInfo) {
		super(env, kind, teamInfo);
		//brain = new AI(teamInfo, env.getRoadSpots(), this);
		brain = new NewAI(this, teamInfo);
	}

	@Override
	public void decide() {
		brain.setDiceNumber(env.getDiceNumber());
		brain.decide();
	}
	
	public List<Spot> getMovableSpots(Horsemen horse) {
		return env.getMovableSpots(horse);
	}
	
	public List<Horsemen> getHorsesInRoad() {
		List<Horsemen> horsesInRoad = new LinkedList<Horsemen>();
		Horsemen[] allHorses = env.getAllHorses();
		for (Horsemen horse : allHorses) {
			if(horse.getState() == HorseState.InRoad){
				horsesInRoad.add(horse);
			}
		}
		return horsesInRoad;
	}

	@Override
	public boolean throwDice(Dice dice) {
		dice.throwDice();
		return true;
	}

}
